package com.park.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.park.dao.WxPaidrecordMapper;
import com.park.model.Park;
import com.park.model.WebUtil;
import com.park.model.WxPaidrecord;
import com.park.service.WxPaidrecordService;

import java.util.List;
import java.util.Map;

@Service
public class WxPaidrecordServiceImpl implements WxPaidrecordService {

    @Autowired
    private WxPaidrecordMapper wxPaidrecordMapper;

    /**
     * 根据openId查询缴费记录
     *
     * @param wxPaidrecord
     * @return
     */
    @Override
    public List<Map<String, Object>> selectWxPaidrecordList(WxPaidrecord wxPaidrecord) {
        return wxPaidrecordMapper.selectWxPaidrecordList(wxPaidrecord);
    }

    /**
     *  添加缴费记录
     * @param wxPaidrecord
     * @return
     */
    @Override
    public boolean insertWxPaidrecord(WxPaidrecord wxPaidrecord) {
        return wxPaidrecordMapper.insertWxPaidrecord(wxPaidrecord);
    }

    /**
     *  修改缴费记录
     * @param wxPaidrecord
     * @return
     */
    @Override
    public boolean updateWxPaidrecord(WxPaidrecord wxPaidrecord) {
        return wxPaidrecordMapper.updateWxPaidrecord(wxPaidrecord);
    }

    /**
     * 根据订单编号查询缴费记录
     * @param outTradeNo
     * @return
     */
    @Override
    public WxPaidrecord selectWxPaidrecordByOutTradeNo(String outTradeNo) {
        return wxPaidrecordMapper.selectWxPaidrecordByOutTradeNo(outTradeNo);
    }

    /**
     * 根据 userId 查询缴费记录
     *
     * @param wxPaidrecord
     * @return
     */
    @Override
    public List<Map<String, Object>> selectWxPaidrecordListByUserId(WxPaidrecord wxPaidrecord) {
        return wxPaidrecordMapper.selectWxPaidrecordListByUserId(wxPaidrecord);
    }

    /**
     * 根据 userId,paidTime 查询缴费记录并且分页
     *
     * @param webUtil
     * @return
     */
	@Override
	public List<WxPaidrecord> selectWxPaidrecordListByUserIdV2(WebUtil webUtil) {
		// TODO Auto-generated method stub
		webUtil.setStartPage((webUtil.getStartPage()-1)*webUtil.getPageSize());
		return wxPaidrecordMapper.selectWxPaidrecordListByUserIdV2(webUtil);
	}

	 /**
     * 根据 userId,paidTime 查询缴费记录总数
     *
     * @param webUtil
     * @return
     */
	@Override
	public int selectWxPaidrecordListByUserIdCount(WebUtil webUtil) {
		// TODO Auto-generated method stub
		return wxPaidrecordMapper.selectWxPaidrecordListByUserIdCount(webUtil);
	}

	 /**
     * 根据 userId,startTime,endTime 查询停车场
     * @param webUtil
     * @return
     */
	@Override
	public List<Park> getParkByUserId(WebUtil webUtil) {
		// TODO Auto-generated method stub
		return wxPaidrecordMapper.getParkByUserId(webUtil);
	}
}
